package com.resou.reader.mine.vipcenter.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.data.bookstore.model.PlateNovels;

import java.util.List;

/**
 * 查看更多适配器
 */
public class MonthlyMoreAdapter extends BaseQuickAdapter<PlateNovels, BaseViewHolder> {
    boolean isShowFree = true;

    public MonthlyMoreAdapter(int layoutResId, @Nullable List<PlateNovels> data) {
        super(layoutResId, data);
    }

    public MonthlyMoreAdapter(@Nullable List<PlateNovels> data) {
        super(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PlateNovels item) {
        if (isShowFree) {
            helper.setVisible(R.id.ivFree, true);
        } else {
            helper.setVisible(R.id.ivFree, false);
        }
        helper.addOnClickListener(R.id.llOnclick)
                .setText(R.id.tvBookName, item.getNovelName() + "")
                .setText(R.id.tvBookContent, item.getNovelDescription() + "")
                .setText(R.id.tv_author, item.getAuthorName() + " · " + item.getSerialStatus() + " · " + item.getTotalWord() + "")
                .setText(R.id.tvType, item.getNovelCategoryName() + "");
        Glide.with(mContext).load(item.getCoverUrl() + "").into((ImageView) helper.getView(R.id.iv_cover));
    }

    public boolean isShowFree() {
        return isShowFree;
    }

    public void setShowFree(boolean showFree) {
        isShowFree = showFree;
    }
}
